package com.motorola.dp.jenkinsmonitor.webapp.config;

import java.util.Properties;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.motorola.dp.jenkinsmonitor.service.util.properties.ClasspathPropertiesService;

@Configuration
@EnableScheduling
@ComponentScan({
    "com.motorola.dp.jenkinsmonitor.service",
    "com.motorola.dp.jenkinsmonitor.webapp.controllers"
    })
public class ContextConfig {

    @Bean
    public PropertyPlaceholderConfigurer properties() {
        PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
        configurer.setProperties(applicationProperties());
        return configurer;
    }

    @Bean
    public Properties applicationProperties() {
        return ClasspathPropertiesService.readPropsFromClasspath("application.properties");
    }


}
